﻿using System;
using System.Collections.Generic;
using System.Data;
using IFRS.DataAccess.DAL;
using IFRS.Models;
using IFRS.Web;
using IFRS_Global;

public partial class IFRS_WIN14_3V : PageBase
{
    #region "---------- Events -----------"

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(Page.IsPostBack || Page.IsCallback))
        {
            this.ViewMenu();
            this.BindDLL();
            if (Request.QueryString["id"].ToString() != null)
            this.BindData(Convert.ToInt32(Request.QueryString["id"].ToString()));
        }
        else
            ClientScript.RegisterHiddenField("isPostBack", "1");
    }

    protected void btnCANCEL_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/IFRS/WIN14_1S.aspx");
    }

    #endregion

    #region "----- Methods -------"

    private void ViewMenu()
    {
        this.MenuTitleBar = Resources.ifrsMenu.WIN14_3V;
    }
    private void BindDLL()
    {
        ddlSourceData.SetData(DDL_TYPE.SourceData, "", false, true);
        ddlTypeOfCost_Income.SetData(DDL_TYPE.FeeAndCostTypeName, "", false, true);
    }

    private void BindData(int ID)
    {
        if (Request.QueryString["id"] == null)
            return;

        var FEEANDCOST = new FEEANDCOST();
        DataTable dtFEEANDCOST = FEEANDCOST.SEARCH_BYID(ID);
        List<FeeAndCost> FeeAndCost = new List<FeeAndCost>();
        ConvertHelper.ConvertDataTableToObject(dtFEEANDCOST, FeeAndCost);
        if (dtFEEANDCOST.Rows.Count > 0)
        {
            //txtDATE_TRANSACTION.Text = FeeAndCost[0].TransactionDate.Value.ToString("dd/MM/yyyy");
            txtDATE_TRANSACTION.Text = FeeAndCost[0].TransactionDate.DateToString();

            if (FeeAndCost[0].DataType.ToString() == "1")
                radDATA_TYPE1.Checked = true;
            else if (FeeAndCost[0].DataType.ToString() == "2")
                radDATA_TYPE2.Checked = true;

            if(FeeAndCost[0].SourceDataID.ToString()!="")
            ddlSourceData.SelectedValue = FeeAndCost[0].SourceDataID.ToString();

            if (FeeAndCost[0].FeeAndCostTypeID.ToString() != "")
                ddlTypeOfCost_Income.SelectedValue = FeeAndCost[0].FeeAndCostTypeID.ToString();

            txtAccountNo_ContractNumber.Text = FeeAndCost[0].AccountNo;
            txtAmount.Text = FeeAndCost[0].Amount.ToString();

        }
    }

        #endregion

}